<?php

/*

Upgrade Shop (upgrade_shop.php)

*/

$page_title = "Upgrade Shop";
$rank_check = 1;
include "header.inc.php";

print "$openHTML";

$find_shop = fetch("SELECT * FROM usershops2 WHERE owner = '$userid' AND game = '$game'");

if (!$find_shop[id])
{
	die("You do not have a shop yet, please click <a href=makeshop.php?game=$game>here</a> to create one.$closeHTML");
}

$max_stock = $find_shop[shop_size] * 5;
$cost_2_upgrade = ($find_shop[shop_size] * 50) + 50;
$next_level = $find_shop[shop_size] + 1;

$findTokens = fetch("SELECT * FROM upgrade_tokens WHERE user = '$userid' AND game = '$game' AND upgrade = 'shop'");
if (!$findTokens[ammount]) { $findTokens[ammount] = 0; }

ECHO <<<END

<p align=center><a href=myshop.php?game=$game>My Stock</a> | <a href=edit_shop.php?game=$game>Edit Shop</a> | <a href=usershop.php?game=$game&user=$username>View Shop</a> | <a href=upgrade_shop.php?game=$game>Upgrade Shop</a> | <a href=sales_log.php?game=$game>Sales Log</a></p>

<P><FORM ACTION="upgrade_shop.pro.php?game=$game&next_upgrade=$next_level" METHOD=POST>
   <CENTER><BR>
   <TABLE BGCOLOR="$tableOutline" CELLSPACING=1 CELLPADDING=0 WIDTH=450>
      <TR BGCOLOR="$topAndBottomBG">
         <TD WIDTH=100 HEIGHT=50>
            <CENTER class=white><FONT SIZE="+2" COLOR="$topAndBottomText"><B>--Upgrade
            Your Shop--</B></FONT></CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="#FFFFFF">
         <TD WIDTH=100 HEIGHT=25>
            <CENTER>Your shop is currently size <B>$find_shop[shop_size]</B> which means
            it can hold <B>$max_stock</B> items</CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="$reallyLight">
         <TD WIDTH=100 HEIGHT=25>
            <CENTER>It will cost <B>$cost_2_upgrade $pointsVar</B> to upgrade your
            shop! <INPUT TYPE=submit NAME=upgrade VALUE="Upgrade to size $next_level"></FORM></CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="#FFFFFF">
         <TD WIDTH=100 HEIGHT=25>
            <FORM ACTION="upgrade_shop.pro.php?game=$game&next_upgrade=$next_level&use_token=true" METHOD=POST><CENTER><a href=upgrade_tokens.php?game=$game>Upgrade Tokens</a>: $findTokens[ammount] <input type=submit value="Use Token!"></CENTER></form>
         </TD>
      </TR>
   </TABLE>
   </CENTER>
</P>

END;

print "$closeHTML";
?>